
use "Kapoor_Magesan_RTI_RD_Analysis.dta", clear

**************************************************************************************************
*									RD Baseline: Table 4										 *
**************************************************************************************************

// Baseline: RD regression using HHI/State designation definition of regional party
*Panel 1: All 
	preserve
	keep if (RegTopTwo==1)
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore
	
	
*Panel 2: A Non-Regionalist Party Governs State
	preserve
	keep if (RegTopTwo==1)&(RegMostTopTwo==0)
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore	

	
*Panel 3: Regionalist Party that Wins the Constituency does not Control State Gov't, INC or BJP Governs
*		  Do same RD but only keep observations where the regional party in top two was NOT state govt and State winner was either INC or BJP  	
	preserve
	keep if (RegTopTwo==1)&(RegMostTopTwo==0)&(winner1=="INC"|winner1=="BJP")
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore	
	
*Panel 4: Regionalist Party that Wins the Constituency Also Controls State Gov't 
*		  Do same RD but only keep observations where the regional party in top two was state govt
	preserve
	keep if (RegTopTwo==1)&(RegMostTopTwo==1)
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore	
	
*Panel 5: Regionalist Party that Wins the Constituency is aligned with the National (federal) Alliance/Coalition
*		  Do same RD but only keep observations where the regional party in top two is aligned with national coalition	
	preserve
	keep if (RegTopTwo==1)&(NatCoal==1) 
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore	
	
	
*Baseline Figure 3
	graph drop _all 
	preserve
	keep if RegTopTwo==1
	rdrobust event rdrunning_reg, p(1) vce(cluster constituency) 
	scalar b = round(e(tau_cl),.001)
	scalar p = round(e(pv_cl),.001)
	rdplot event rdrunning_reg if abs(rdrunning_reg)<=0.0499, p(1) nbins(30 30) graph_options(yla(, format(%03.2f)) ytitle("Occurrence of Violence") ysc(titlegap(2)) xla(, format(%03.2f))  title("est. = `=scalar(b)', p = `=scalar(p)'") name(Event,replace) legend(off))scalar drop b p
	restore
	
// Density test: Figure 4
net install rddensity, from(https://raw.githubusercontent.com/rdpackages/rddensity/master/stata) replace
net install lpdensity, from(https://raw.githubusercontent.com/nppackages/lpdensity/master/stata) replace

	preserve
	keep if (RegTopTwo==1)
	hist rdrunning_reg, bin(50) xtitle("") xlab(,format(%03.2f))						
	rddensity rdrunning_reg, p(2) q(3) plot 
	restore
	
	
*TABLE 5 IV Estimates of Aggregate and Spillover Effects 
	preserve
	use "Kapoor_Magesan_RTI_RDIV_Data.dta", clear
	*(Panel A. All Constituencies)
	eststo: ivreghdfe incidence (RF=RCF), absorb(ones) cluster(unit) first 
	eststo: ivreghdfe incidence CF LagIncidence (RF=RCF), absorb(ones) cluster(unit) first 
	eststo: ivreghdfe incidence CF LagIncidence (RF=RCF), absorb(stdum units) cluster(unit) first 
	*(Panel A. Regionalist Held Constituencies)
	eststo: ivreghdfe regincidence (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe regincidence CF Lagregincidence (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe regincidence CF Lagregincidence (RF=RCF), absorb(stdum units) cluster(unit) 
	*(Panel A. Non-Regionalist Constituencies)
	eststo: ivreghdfe nonregincidence (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe nonregincidence CF Lagnonregincidence (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe nonregincidence CF Lagnonregincidence (RF=RCF), absorb(stdum units) cluster(unit)  
	*(Panel B. All Constituencies)
	eststo: ivreghdfe lnum_events (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe lnum_events CF Laglnum_events (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe lnum_events CF Laglnum_events (RF=RCF), absorb(stdum units) cluster(unit)  
	 *(Panel B. Regionalist Constituencies)
	eststo: ivreghdfe lnumreg_events (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe lnumreg_events CF Laglnumreg_events (RF=RCF), absorb(ones) cluster(unit)  
	eststo: ivreghdfe lnumreg_events CF Laglnumreg_events (RF=RCF), absorb(stdum units) cluster(unit)  
	*(Panel C. Non-Regionalist Constituencies)
	eststo: ivreghdfe lnumnonreg_events (RF=RCF), absorb(ones) cluster(unit) first 
	eststo: ivreghdfe lnumnonreg_events CF Laglnumnonreg_events (RF=RCF), absorb(ones) cluster(unit) first 
	eststo: ivreghdfe lnumnonreg_events CF Laglnumnonreg_events (RF=RCF), absorb(stdum units) cluster(unit) first 
	restore 	

*TABLE 6 Regionalism and Tribal Insecurity

//Panel A. Effect in ST-Reserved
	preserve
	keep if (RegTopTwo==1)&(tagST==1)
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore
//Panel B. Effect in non-ST-Reserved
	preserve
	keep if (RegTopTwo==1)&(tagST==0)
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore
	
//Panel C. Effect in ST-reserved with below median tribal population 
	preserve
	keep if (RegTopTwo==1)&(tagST==0)
	egen med_tribal = median(AD_tribalpc11)
	keep if (AD_tribalpc11<=med_tribal)&(AD_tribalpc11!=.)
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore
	
//Panel D. Effect in ST-reserved with above median tribal population 
	preserve
	keep if (RegTopTwo==1)&(tagST==0)
	egen med_tribal = median(AD_tribalpc11)
	keep if (AD_tribalpc11>med_tribal)&(AD_tribalpc11!=.)
	rdrobust event rdrunning_reg, vce(cluster constituency) p(1)
	summ event 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust lnum_events rdrunning_reg, vce(cluster constituency) p(1)
	summ lnum_events 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r) 
	rdrobust death rdrunning_reg, vce(cluster constituency) p(1)
	summ death 
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	rdrobust lbest_est rdrunning_reg, vce(cluster constituency) p(1)
	summ lbest_est
	di e(h_l) 
	di e(N_h_l)+e(N_h_r)
	restore
	

